using Domain.Services;
using Domain.Entities;
using Domain.Entities.Enums;
using System;

namespace Domain.Permissions
{
    public class ForumPermissionManager
    {
        private bool read;
        private bool reply;
        private bool vote;
        private bool createTopic;
        private bool createPoll;
        private bool createSticky;
        private bool createAnnouncement;
        private bool createFaq;
        private bool editOwn;
        private bool deleteOwn;
        private bool moderate;

        internal ForumPermissionManager(Permission permission)
        {
            read = (permission & Permission.Read) != 0;
            reply = (permission & Permission.Reply) != 0;
            vote = (permission & Permission.Vote) != 0;
            createTopic = (permission & Permission.CreateTopic) != 0;
            createPoll = (permission & Permission.CreatePoll) != 0;
            createSticky = (permission & Permission.CreateSticky) != 0;
            createAnnouncement = (permission & Permission.CreateAnnouncement) != 0;
            createFaq = (permission & Permission.CreateFaq) != 0;
            editOwn = (permission & Permission.EditOwn) != 0;
            deleteOwn = (permission & Permission.DeleteOwn) != 0;
            moderate = (permission & Permission.Moderate) != 0;
        }

        public bool Read
        {
            get { return read; }
        }

        public bool Reply
        {
            get { return reply; }
        }

        public bool Vote
        {
            get { return read; }
        }

        public bool CreateTopic
        {
            get { return createTopic; }
        }

        public bool CreatePoll
        {
            get { return createPoll; }
        }

        public bool CreateSticky
        {
            get { return createSticky; }
        }

        public bool CreateAnnouncement
        {
            get { return createAnnouncement; }
        }

        public bool CreateFaq
        {
            get { return createFaq; }
        }

        public bool EditOwn
        {
            get { return editOwn; }
        }

        public bool DeleteOwn
        {
            get { return deleteOwn; }
        }

        public bool Moderate
        {
            get { return moderate; }
        }
    }
}
